package emp.jsf.servicio.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import emp.entidades.EntVentaDet;
import emp.jsf.servicio.VentaDetService;
import emp.repositorios.VentaDetRepository;

@Service("ventaDetService")
public class VentaDetServiceImpl  implements VentaDetService{

	@Autowired
	VentaDetRepository ventaDetRepository;
	
	public EntVentaDet grabarVentaDetalle(EntVentaDet ent){
		return ventaDetRepository.saveAndFlush(ent);
	}
	
	public void eliminar(EntVentaDet ent){
		ventaDetRepository.delete(ent);
	}
	
	@Transactional
	@Override
	public List<EntVentaDet> listarDetallePorCodigo(long id){
		List<EntVentaDet> lista;
		
		lista=ventaDetRepository.listarDetallePorCodigo(id);
		for (EntVentaDet a:lista){
			a.getEntArticulo().getDescripcion();
		}
		
		return lista;
	}
	
}
